<!-- 事物类别 -->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="my" uri="http://www.trkj.com/tr1702/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>事物类别</title>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/locale/easyui-lang-zh_CN.js"/>"></script>
<link rel="stylesheet" type="text/css"
	href="<c:url value="/js/jquery-easyui-1.5.5.6/themes/default/easyui.css"/>" />
<link rel="stylesheet" type="text/css"
	href="<c:url value="/js/jquery-easyui-1.5.5.6/themes/icon.css"/>" />
</head>
<body>
	<script type="text/javascript">
	var what_category_state= function(value,row,index){
		var pic="";
		var state = row.AFFCA_STATE;
		if(state==0){
			pic = "<input type='checkbox' disabled='disabled'>";
		}else if(state==1){
			pic="<input type='checkbox' checked disabled='disabled'>";
		}
		return pic;
	}
	var what_category_button =function(value,row,index){
		var only_what_category ="";
		var edit_what_category ="";
		var del_what_category ="";
		 <my:g id="51">only_what_category = "<a style='' btn='what_category_only' onclick='aff_onlyrule(" + row.AFFCA_ID + ","+row.AFFCA_STATE+")'></a>";</my:g>
		 <my:g id="52">edit_what_category = "<a style='' btn='what_category_edit' onclick='aff_editrule(" + row.AFFCA_ID + ")'></a>";</my:g>
		 <my:g id="53">del_what_category = " <a btn='what_category_del' onclick='aff_delrule(" + row.AFFCA_ID + ")'></a>";</my:g>
		return  only_what_category +edit_what_category +del_what_category; 
	}
		/*禁用*/
		var aff_onlyrule =function(affcaId,affcaState){
			$('#update-what_category').dialog("close");
			var jy_state =1;
			if(affcaState==1){
				jy_state=0;
				$.messager.confirm('确认', '您确定要打开该事务类别吗？', function(v){
					if(v){
						$.post("update_affaircategorystate", {affcaId: affcaId,affcaState:jy_state}, function(v){
							if(v.success){
								$('#what_category_tb').datagrid('reload');
							}else{
								$.messager.alert('错误', v.message);
							}
						});
					}else{
						
					}
					
				}); 
			}else if(affcaState==0){
				jy_state=1;
				$.messager.confirm('确认', '您确定要关闭该事务类别吗？', function(v){
					if(v){
						$.post("update_affaircategorystate", {affcaId: affcaId,affcaState:jy_state}, function(v){
							if(v.success){
								$('#what_category_tb').datagrid('reload');
							}else{
								$.messager.alert('错误', v.message);
							}
						});
					}else{
						
					}
					
				}); 
			}
		}
		/*修改*/
		var aff_editrule=function(affcaId){
			$('#update-what_category').dialog("open");
			$('#what_category_update').form('load','load_affaircategory?affcaId='+affcaId);
		}
		/*删除*/
		var aff_delrule= function(affcaId){
			$('#update-what_category').dialog("close");
			$.messager.confirm('确认','您确认要删除事务类别吗？',function(v){
				if(v){
					$.post("is_del_affaircategory",{affcaId:affcaId},function(v){
						if(v.success){
							$('#what_category_tb').datagrid('reload');
						}else{
							$.messager.alert('错误',v.message);
						}
					});
				}else{
					
				}
				
			});
		}
		$(function() {
			$("#add_category").linkbutton({
				onClick : function() {
					$("#dd-what_category").dialog("open");
				}
			});
			$("#what_category_tb").datagrid({
				onLoadSuccess:function(){
					$("a[btn=what_category_edit]").linkbutton({iconCls:'icon-update_red', plain:true});
					$("a[btn=what_category_del]").linkbutton({iconCls:'icon-delete_red', plain:true});
					$("a[btn=what_category_only]").linkbutton({iconCls:'icon-changes', plain:true});
				}
			});
			//模糊搜索
			$("#what_category_seebyname").linkbutton({
				onClick:function(){
					var SeeText = $("#what_category_seebytext").textbox("getText");
					 $("#what_category_tb").datagrid({url:'to_affaircategoryByName?affcaName='+SeeText,method:'get'});
					$("#what_category_tb").datagrid("reload"); 
				}
			});
			//双击修改
			<my:g id="52">$('#what_category_tb').datagrid({
				onDblClickRow: function(index, row){
					$('#update-what_category').dialog("open");
					$('#what_category_update').form('load','load_affaircategory?affcaId='+row.AFFCA_ID);
				}
			});
			</my:g>
			//

		});
		//进入时加载
		$(document).ready(function(){
			
		});
		//刷新
		$("#what_category_reload").linkbutton({
			onClick:function(){
				$('#what_category_tb').datagrid('reload');
			}
		});
		 
	</script>
	<table id="what_category_tb" class="easyui-datagrid" style="width: 400px; height: 250px"
		data-options="
				fitColumns:true,
				fit:true,
       			url:'to_affaircategoryss',
       			method:'post',
				pagination:true,     
				pageSize:5,     
				pageList: [5,10,15,20,25], 
				rownumbers:true,
				Striped:true, 
				singleSelect:true,
				striped:true,
				toolbar:'#tool_what_category'
        ">
		<thead>
			<tr>
				<th data-options="field:'AFFCA_ID',width:30,align:'center'">编号</th>
				<th data-options="field:'AFFCA_NAME',width:70,align:'center'">名称</th>
				<th data-options="field:'AFFCA_TYPE',width:70,align:'center'">应用类型</th>
				<th data-options="field:'AFFCA_OVERTIME',width:30,align:'center'">加班种类</th>
				<th data-options="field:'AFFCA_FOUNDDATE',width:80,align:'center',formatter:function(value,row,index){
					if(value!=null){
						var date = new Date(value);
						return date.toLocaleString();
					}
						return;
				}">创建日期</th>
				<th data-options="field:'AFFCA_UPDATE',width:50,align:'center',formatter:function(value,row,index){
					if(value!=null){
						var date = new Date(value);
						return date.toLocaleString();
					}
						return;
				}">更新日期</th>
				
				<th data-options="field:'AFFCA_PERSON',width:70,align:'center'">创建人</th>
				<th data-options="field:'AFFCA_STATE',width:70,align:'center',formatter:what_category_state">状态</th>
				<th data-options="field:'xx',width:70,align:'center',formatter:what_category_button"></th>
			</tr>
		</thead>
		<tbody>
		</tbody>
	</table>
	<!--工具-->
	<div id="tool_what_category" style="padding-left: 30px;">
		<my:g id="50"><a class="easyui-linkbutton add_result"
			data-options="iconCls:'icon-add'" id="add_category">新增</a></my:g>
			<a id="what_category_reload" class="easyui-linkbutton" data-options="iconCls:'icon-reload'"></a>
			<input class="easyui-textbox" id="what_category_seebytext" data-options="prompt:'请输入名称'"> <a class="easyui-linkbutton"
			data-options="text:'搜索'" id="what_category_seebyname"> </a>
			
	</div>

	<div id="dd-what_category" class="easyui-dialog" title="规则结果"
		data-options="
         width:400,
         height:240,
	     resizable:false,
	     modal:true,
	     closed:true,
	     buttons:[{
				text:'添加',
				width:60,
				handler:function(){
					$('#what_category_add').form({
						url:'is_add_affaircategory',
						method:'get',
						onSubmit:function(params){
							params['affcaName']=$('.add_what_category_name').textbox('getText');
							params['affcaType']=$('.add_what_category-affair').val();
							params['affcaOvertime']=$('.add_what_category_affair').val();
							if($('.add_what_category_shop').is(':checked')){
								params['affcaState']=parseInt(1);
							}else{
								params['affcaState']=parseInt(0);
							}
							
								return $('#what_category_add').form('validate');
						},
						success:function(v){
							v = eval('('+v +')');
							if(v.success){
								$.messager.alert('恭喜', '添加成功');
							}else{
								$.messager.alert('错误', '对不起，操作失败，原因：' + v.message);
							}
						$.messager.progress('close');// 如果提交成功则隐藏进度条
						$('#what_category_tb').datagrid('reload');
						$('#what_category_add').form('reset');
						$('#dd-what_category').dialog('close');
						}
					}).submit();
				}
				},{
				text:'继续添加',
				width:80,
				handler:function(){
					$('#what_category_add').form({
						url:'is_add_affaircategory',
						
						onSubmit:function(params){
							params['affcaName']=$('.add_what_category_name').textbox('getText');
							params['affcaType']=$('.add_what_category-affair').val();
							params['affcaOvertime']=$('.add_what_category_affair').val();
							if($('.add_what_category_shop').is(':checked')){
								params['affcaState']=parseInt(1);
							}else{
								params['affcaState']=parseInt(0);
							}
	
								return $('#what_category_add').form('validate');
						},
						success:function(v){
							v = eval('('+v +')');
							if(v.success){
								$.messager.alert('恭喜', '添加成功');
							}else{
								$.messager.alert('错误', '对不起，操作失败，原因：' + v.message);
							}
						$.messager.progress('close');// 如果提交成功则隐藏进度条
						$('#what_category_tb').datagrid('reload');
						$('#what_category_add').form('reset');
						
						}
					}).submit();
				}
				},{
				text:'取消',
				width:60,	
				handler:function(){
					$('#dd-what_category').dialog('close');
				}
			}]
        ">
		<div style="margin-left: 16%; margin-top: 10px;">
			<form action="" id="what_category_add" style="text-align: right;">
				<table>
					<!-- <tr>
						<td><span style="color: red;">*</span>编号</td>
						<td><input class="easyui-textbox"
							data-options="required:true"></td>
					</tr> -->
					<tr>
						<td><span style="color: red;">*</span>名称</td>
						<td><input class="easyui-textbox add_what_category_name" 
							data-options="required:true" id=""></td>
					</tr>
					<tr>
						<td><span style="color: red;"> </span>应用类型</td>
						<td>
							<select id="yylx-value-affair" class="easyui-combobox add_what_category-affair"
								style="width: 170px;" data-options="panelHeight:'auto'">
									<option value="公司事务">公司事务</option>
									<option value="加班事务">加班事务</option>
									<option value="调休事务">调休事务</option>
									<option value="补班事务">补班事务</option>
									<option value="外勤事务">外勤事务</option>
							</select>
						</td>
					</tr>
					<tr>
						<td><span style="color: red">*</span>加班类型</td> 
						<td><select id="jblx_affair" class="easyui-combobox add_what_category_affair"
								style="width: 170px;" data-options="panelHeight:'auto'">
									<option value=" "> </option>
									<option value="平时加班">平时加班</option>
									<option value="休息加班">休息加班</option>
									<option value="假日加班">假日加班</option>
							</select></td>
					</tr>
					<!-- <tr>
						<td><span style="color: red;"> </span>备注</td>
						<td><input class="easyui-textbox" data-options="height:60,multiline:true" id="rule_result_marks--affair"></td>
					</tr> -->
					<tr>
						<td><span style="color: red;"> </span></td>
						<td><span style="padding-right:5px;">停用</span>
						<input type="checkbox" value='0' class="add_what_category_shop">
					</tr>
				</table>
			</form>
		</div>
	</div>
	
	<!-- 修改 -->
	<div id="update-what_category" class="easyui-dialog" title="事务类别"
		data-options="
        width:400,
         height:240,
	     resizable:false,
	     modal:true,
	     closed:true,
	     buttons:[{
				text:'保存',
				width:60,
				handler:function(){
					$('#update_what_category').form({
						url:'is_update_affaircategory',
						onSubmit:function(params){
							params['affcaId']=$('#affair_ids').textbox('getText');
							
							params['affcaName']=$('#affair_name').textbox('getText');
							params['affcaType']=$('.cfyx-affair').val();
							
							params['affcaOvertime']=$('.work_leibie-affair').val();
							if($('.affair_check').is(':checked')){
								params['affcaState']=parseInt(1);
							}else{
								params['affcaState']=parseInt(0);
							}
							
								return $('#update_what_category').form('validate');
						},
						success:function(v){
							v = eval('('+v +')');
							if(v.success){
								$.messager.alert('恭喜', '修改成功');
							}else{
								$.messager.alert('错误', '对不起，操作失败，原因：' + v.message);
							}
						$.messager.progress('close');// 如果提交成功则隐藏进度条
						$('#what_category_tb').datagrid('reload');
						$('#update-what_category').dialog('close');
						}
					}).submit();
				}
				},{
				text:'取消',
				width:60,	
				handler:function(){
					$('#update-what_category').dialog('close');
				}
			}]
        ">
		<div style="margin-left: 16%; margin-top: 10px;">
			<form action="" id="what_category_update" style="text-align: right;">
				<table>
					<tr style="display:none;">
						<td><span style="color: red;">*</span>id</td>
						<td><input class="easyui-textbox"
							data-options="required:true" id="affair_ids" name="affcaId"></td>
					</tr>
					<tr>
						<td><span style="color: red;">*</span>名称</td>
						<td><input class="easyui-textbox"
							data-options="required:true" id="affair_name" name="affcaName"></td>
					</tr>
					<tr>
						<td><span style="color: red;"> </span>应用类型</td>
						<td>
							<select id="yylx-value-affair" class="easyui-combobox cfyx-affair" 
								style="width: 170px;" data-options="panelHeight:'auto'" name="affcaType">
									<option value="公司事务">公司事务</option>
									<option value="加班事务">加班事务</option>
									<option value="调休事务">调休事务</option>
									<option value="补班事务">补班事务</option>
									<option value="外勤事务">外勤事务</option>
							</select>
						</td>
					</tr>
					<tr>
						<td><span style="color: red">*</span>加班类型</td> 
						<td>
							<select id="jblx_affair" class="easyui-combobox work_leibie-affair" 
									style="width: 170px;" data-options="panelHeight:'auto'" name="affcaOvertime">
										<option value=" "> </option>
										<option value="平时加班">平时加班</option>
										<option value="休息加班">休息加班</option>
										<option value="假日加班">假日加班</option>
							</select>
						</td>
					</tr>
					<tr>
						<td><span style="color: red;"> </span></td>
						<td><span style="padding-right:5px;">停用</span>
						<input type="checkbox" value='1' id="affair_check" class="affair_check" name="affcaState">
					</tr>
				</table>
			</form>
		</div>
	</div>
	<div>
		<form id="update_what_category" method="post"></form>
	</div>
</body>
</html>